<template>
	<view>

		<view class="pageContainer">
			<!-- 列表 -->
			<view class="errorList_box">
				<view class="errorItem" v-for="(item,index) in errorList" :key="index">
					<view class="errorHead_con">
						<u-image :src="item.userInfo.header_img" shape="square" border-radius="10" width="80rpx"
							height="80rpx" :lazy-load="false" :show-loading="false" 
							:fade="false"></u-image>
						<view class="errorName">{{item.userInfo.name}}</view>
						<view class="errorDate">{{item.woke_date}}</view>
					</view>
					<view class="errorBody_con">
						<view class="statisticsItem">
							<view class="statisticsMoney" v-if="item.type==1">点工：{{item.work_num}}工</view>
							<view class="statisticsMoney" v-if="item.type==1">加班：{{item.work_hour}}H</view>
							<view class="statisticsMoney" v-if="item.type==2">记账：{{item.work_num}}元</view>
							<view class="statisticsType">自己</view>
						</view>
						<view class="statisticsUnequal">≠</view>
						<view class="statisticsItem">
							<view class="statisticsMoney" v-if="item.type==1">点工：{{item.work_num_member}}工</view>
							<view class="statisticsMoney" v-if="item.type==1">加班：{{item.work_hour_member}}H</view>
							<view class="statisticsMoney" v-if="item.type==2">记账：{{item.work_num_member}}元</view>
							<view class="statisticsType">工人</view>
						</view>
					</view>
					<view class="errorFooter_con">
						<view class="errorEdit" @click="errorEdit(item.work_id,item.type,item.id,item)">查看修改</view>
					</view>
				</view>
			</view>

			<!-- 数据为空 -->
			<view class="dataEmpty_con" v-if="errorList.length==0">
				<u-empty></u-empty>
			</view>
		</view>
		
		
		<!-- 记人工组件 -->
		
	</view>
</template>

<script>

	export default {
		
		data() {
			return {
				// 默认工地信息
				defaultWorksite: JSON.parse(uni.getStorageSync('defaultWorksite')),

				// 异常列表
				errorList: [],

				// 类型
				type: 'all', // all全部、1记工、2记账
				billType:1,
			}
		},
		onLoad(option) {
			// uni.showLoading({
			// 	title: '加载中'
			// });
			if (option.type) {
				this.type = option.type;
			}
		},
		onShow() {
			var _this = this;
			_this.getErrorList();
		},
		onReady() {

		},
		methods: {
			// 获取异常列表
			getErrorList() {
				var _this = this;
				_this.$u.get('/api/project.compare/getList', {
					project_id: _this.defaultWorksite.project_id,
					type: _this.type,
					pages: 1,
					limit: 100000,
				}).then(res => {
					uni.hideLoading();
					console.log("==获取异常列表==");
					console.log(res);
					_this.errorList = res.data;
				}).catch(res => {
					console.log(res);
				})
			},

			// 查看修改
			errorEdit(id, type, idData,info='') {
				var _this = this;
				console.log(id, type);
				
				
				
				
				if (type == '1') {
					
					_this.logId=id
					uni.navigateTo({
						url: '/pages/keep/keepEdit?id=' + id
					})
				}
				if (type == '2') {
					uni.navigateTo({
						url: '/pages/bill/billEdit?id=' + id
					})
					
				
					
				// 	uni.navigateTo({
				// 		url: '/pages/bill/billStatistics/billStatistics?project_id='+info['project_id']+'&keyword='+info['userInfo'].name
				// 	})
				}
				
				_this.$u.post('/api/project.compare/readCompare', {
					id: idData,
				}).then(res => {

				})
			},
		}
	}
</script>

<style scoped lang="scss">
	// 列表
	.errorList_box {
		width: 690rpx;
		margin: 0 auto;
		
	}

	.errorItem {
		
		background: #ffffff;
		border-bottom: 10rpx solid #72b6fe;
		margin-top: 30rpx;
		padding: 20rpx 30rpx;
		border-radius: 10rpx;
	}

	.errorHead_con {
		padding: 20rpx 0;
		border-bottom: 1rpx solid #eee;
		overflow: hidden;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.errorName {
		flex: 2;
		margin: 0 20rpx;
	}

	.errorDate {
		color: #999;
	}

	.errorBody_con {
		padding: 30rpx 0;
		overflow: hidden;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.statisticsItem {
		width: 240rpx;
		height: 160rpx;
		text-align: center;
		background: #eef5ff;
		border-radius: 20rpx;
		overflow: hidden;
		display: flex;
		flex-wrap: wrap;
		justify-content: center;
		align-items: center;
		align-content: center;
	}

	.statisticsMoney {
		width: 100%;
		font-size: 30rpx;
		line-height: 40rpx;
		color: $uni-color-primary;
		overflow: hidden;
	}

	.statisticsType {
		width: 100%;
		font-size: 24rpx;
		color: #7D7D7D;
		margin-top: 15rpx;
	}

	.statisticsItem:last-child {
		background: #FFF9F9;
	}

	.statisticsItem:last-child .statisticsMoney {
		color: $uni-color-error;
	}

	.statisticsUnequal {
		font-size: 60rpx;
		color: #D9D9D9;
	}

	.errorFooter_con {
		padding-bottom: 30rpx;
		overflow: hidden;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.errorEdit {
		font-size: 28rpx;
		color: #999;
	}
</style>
